var t = getApp();

Page({
    data: {
        show: !1,
        card_id: "",
        collectNum: 0,
        collectList: [],
        showTitle: "",
        showContent: "",
        showID: "",
        isLoadMore: !0,
        page: 1,
        total_page: 0
    },
    onLoad: function(t) {
        this.setData({
            card_id: t.card_id
        }), this.getNumber(), this.getDate();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this.getMoreData() : console.log("没有更多了");
    },
    onShareAppMessage: function() {},
    showMore: function(t) {
        var a = t.target.dataset.id || t.currentTarget.dataset.id;
        a === this.data.showID ? this.setData({
            showID: ""
        }) : this.setData({
            showID: a
        });
    },
    showWeChat: function(t) {
        var a = t.target.dataset.item || t.currentTarget.dataset.item, e = t.target.dataset.name || t.currentTarget.dataset.name;
        this.setData({
            show: !0,
            showTitle: e
        }), "微信" === e ? this.setData({
            showContent: a.card.card_wechat
        }) : "电话" === e && this.setData({
            showContent: a.card.card_mobile
        });
    },
    getNumber: function() {
        var a = this, e = t.getNetAddresss("plugin.business-card.frontend.controllers.statistics.my-collection.index");
        e += "&card_id=" + this.data.card_id, t._getNetWork({
            url: e,
            success: function(t) {
                var e = t.data;
                1 == e.result ? a.setData({
                    collectNum: e.data
                }) : wx.showToast({
                    title: e.msg,
                    icon: "none"
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getDate: function() {
        var a = this, e = t.getNetAddresss("plugin.business-card.frontend.controllers.statistics.my-collection.get-list");
        e += "&card_id=" + this.data.card_id + "&page=1", t._getNetWork({
            url: e,
            success: function(t) {
                var e = t.data;
                1 == e.result ? (a.setData({
                    isLoadMore: !0,
                    total_page: e.data.last_page,
                    collectList: e.data.data
                }), a.data.total_page || a.setData({
                    total_page: 0
                })) : wx.showToast({
                    title: e.msg,
                    icon: "none"
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getMoreData: function() {
        var a = this;
        if (this.setData({
            isLoadMore: !1
        }), !(this.data.page >= this.data.total_page)) {
            var e = this.data.page + 1;
            this.setData({
                page: e
            });
            var s = t.getNetAddresss("plugin.business-card.frontend.controllers.statistics.my-collection.get-list");
            s += "&card_id=" + this.data.card_id + "&page=" + this.data.page, t._getNetWork({
                url: s,
                success: function(t) {
                    var e = t.data;
                    if (1 == e.result) {
                        var s = e.data.data.concat(a.data.collectList);
                        a.setData({
                            collectList: s
                        });
                    } else {
                        wx.showToast({
                            title: e.msg,
                            icon: "none"
                        });
                        var o = a.data.page - 1;
                        a.setData({
                            page: o,
                            isLoadMore: !1
                        });
                    }
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    },
    goToBackCard: function(t) {
        var a = t.target.dataset.item || t.currentTarget.dataset.item;
        wx.navigateTo({
            url: "/packageB/member/business_card/BusinessCard/BusinessCard?mark=card&card_id=" + a.card_id
        });
    },
    closePu: function() {
        this.setData({
            show: !1
        });
    }
});